import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect: "/index", // 路由的从定向
    children: [
      {
        path: "index",
        name: "Index",
        component: () => import('../views/home/index.vue')
      },
      {
        path: "cate",
        name: "Cate",
        component: () => import('../views/home/cate.vue')
      },
      {
        path: "cart",
        name: "Cart",
        component: () => import('../views/home/cart.vue')
      }, {
        path: "user",
        name: "User",
        component: () => import('../views/home/user.vue')
      }
    ]
  },
  {
    path: '/goods',
    name: 'Goods',
    component: () => import(/* webpackChunkName: "goods" */ '../views/goods.vue')
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import(/* webpackChunkName: "goods" */ '../views/search.vue')
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import(/* webpackChunkName: "goods" */ '../views/detail.vue')
  },
  {
    path: '/address',
    name: 'Address',
    component: () => import(/* webpackChunkName: "goods" */ '../views/address.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import(/* webpackChunkName: "goods" */ '../views/login.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
